package com.woniu.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.woniu.entity.CreMessage;
import com.woniu.service.CreditMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
@RequestMapping("/credit/message")
public class CreditMessageController extends BaseController {
    @Autowired(required = false)
    private CreditMessageService creditMessageService;

    /*
    * 站内信未读信息查询
    * */
    @GetMapping ("/findAll")
    public TableDataInfo findAllMessage( CreMessage creMessage) {
        startPage();
        List<CreMessage> list = creditMessageService.findAllMessage(creMessage);
        return getDataTable(list);
    }
    /*
    * 站内信已读信息查询
    * */
    @GetMapping ("/read")
    public TableDataInfo readMessage( CreMessage creMessage) {
        startPage();
        List<CreMessage> list = creditMessageService.readMessage(creMessage);
        return getDataTable(list);
    }
    /*
     * 根据id查询信息
     * */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") int id) {
        return AjaxResult.success(creditMessageService.findMessageById(id));
    }
    /*
     * 修改状态
     * */
    @PutMapping("/{id}/{readStatus}")
    public AjaxResult editOneType(@PathVariable String readStatus, @PathVariable Integer id) {
        return toAjax(  creditMessageService.editOneType(readStatus, id));
    }
}
